Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a separate PaymentSendFailure for idempotency violation #1826

Merged
merged 2 commits into from
Nov 16, 2022

Conversation

TheBlueMatt
Copy link
Collaborator

Built on #1761, admittedly this should have gone into #1761 but that's done now and I was thinking I really wanted to overhaul the error types entirely, which I'm not sure is really true now.

When a user attempts to send a payment but it fails due to
idempotency key violation, they need to know that this was the
reason as they need to handle the error programmatically
differently from other errors.

Here we simply add a new PaymentSendFailure enum variant for
DuplicatePayment to allow for that.

@TheBlueMatt TheBlueMatt added this to the 0.0.113 milestone Nov 2, 2022
@codecov-commenter
Copy link

codecov-commenter commented Nov 2, 2022

Codecov Report

Base: 90.79% // Head: 91.27% // Increases project coverage by +0.47% 🎉

Coverage data is based on head (c7c134c) compared to base (790d26f).
Patch coverage: 58.33% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1826      +/-   ##
==========================================
+ Coverage   90.79%   91.27%   +0.47%     
==========================================
  Files          87       87              
  Lines       47600    51304    +3704     
  Branches    47600    51304    +3704     
==========================================
+ Hits        43218    46826    +3608     
- Misses       4382     4478      +96     
Impacted Files Coverage Δ
lightning/src/ln/functional_test_utils.rs 93.46% <ø> (ø)
lightning/src/ln/payment_tests.rs 98.88% <ø> (ø)
lightning-invoice/src/payment.rs 93.24% <33.33%> (+3.29%) ⬆️
lightning/src/ln/channelmanager.rs 88.84% <62.50%> (+3.45%) ⬆️
lightning/src/ln/functional_tests.rs 97.03% <100.00%> (-0.06%) ⬇️
lightning/src/chain/channelmonitor.rs 90.70% <0.00%> (+0.05%) ⬆️
lightning-net-tokio/src/lib.rs 77.03% <0.00%> (+0.30%) ⬆️
lightning-invoice/src/utils.rs 95.84% <0.00%> (+0.64%) ⬆️
lightning/src/routing/router.rs 92.80% <0.00%> (+1.09%) ⬆️
... and 3 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@TheBlueMatt TheBlueMatt force-pushed the 2022-10-idempotency-err branch 2 times, most recently from 4d46352 to 5fa0a6b Compare November 3, 2022 22:40
@TheBlueMatt
Copy link
Collaborator Author

Rebased after dependent PR merge.

lightning-invoice/src/payment.rs Outdated Show resolved Hide resolved
lightning/src/ln/channelmanager.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM I think

lightning/src/ln/channelmanager.rs Show resolved Hide resolved
@valentinewallace
Copy link
Contributor

CI sad

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after squash

It was pointed out that its quite confusing that
`AllFailedRetrySafe` does not allow you to call `retry_payment`,
though the documentation on it does specify this. Instead, we
simply rename it to `AllFailedResendSafe` to indicate that the
action that is safe to take is *resending*, not *retrying*.
When a user attempts to send a payment but it fails due to
idempotency key violation, they need to know that this was the
reason as they need to handle the error programmatically
differently from other errors.

Here we simply add a new `PaymentSendFailure` enum variant for
`DuplicatePayment` to allow for that.
@TheBlueMatt
Copy link
Collaborator Author

Squashed without further change.

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Two tiny doc nits, but feel free to merge as is.

/// for this payment.
AllFailedResendSafe(Vec<APIError>),
/// Indicates that a payment for the provided [`PaymentId`] is already in-flight and has not
/// yet completed (i.e. generated an [`Event::PaymentSent`]) or been abandoned (via
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// yet completed (i.e. generated an [`Event::PaymentSent`]) or been abandoned (via
/// yet completed (i.e. generated an [`Event::PaymentSent`]) or has been abandoned (via

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - "not yet completed or been abandoned" has the opposite meaning from "not yet completed or has been abandoned" :).

PathParameterError(Vec<Result<(), APIError>>),
/// All paths which were attempted failed to send, with no channel state change taking place.
/// You can freely retry the payment in full (though you probably want to do so over different
/// You can freely resend the payment in full (though you probably want to do so over different
/// paths than the ones selected).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// paths than the ones selected).
/// paths than the ones previously selected).

Copy link
Collaborator Author

@TheBlueMatt TheBlueMatt Nov 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would rather replace selected with attempted, but not sure its worth it - I don't think anyone is gonna be confused here.

@TheBlueMatt TheBlueMatt merged commit d6aa1bc into lightningdevkit:main Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants